<template>
  <div class="employee-message">
    <h1>hello</h1>
    <button @click="socket();">socket</button>
    <br/>
    <span>{{hehe}}</span>
    <br/>
    <input v-model="hehe"/>
    <br/>
    <span>{{heha}}</span>
    <br/>
    <input v-model="heha"/>
  </div>
</template>

<script>
export default {
  data(){
    return{
      "hehe": 'hehe',
      "heha": ''
    }
  },
  methods: {
    socket() {
      var ws = new WebSocket(
        "ws://192.168.1.50:9000/video?url=" +
        encodeURI("rtsp://192.168.0.220/user=admin&password=&channel=1&stream=0")
      );
      ws.onopen = function() {
        console.log("open");
        ws.send("hello");
      };
      ws.onmessage = function(evt) {
        console.log(evt.data);
      };
      ws.onclose = function(evt) {
        console.log("WebSocketClosed!");
      };
      ws.onerror = function(evt) {
        console.log("WebSocketError!");
      };
    }
  }
};
</script>

<style scoped>
</style>
